using I2.Loc;
using UnityEngine;

public class AchivmentProfilePanel : MonoBehaviour
{
	public Achievement achievement;

	public UILabel[] achivmentName;

	public UILabel achivmentDescription;

	public UISprite achivmentIcon;

	public UILabel achivmentCount;

	public UISprite[] progressBar;

	public UISprite checkSprite;

	public UISprite panel;

	public RewardUIPanel rewardPanel;

	public void Init(Achievement achivment, bool initProgressOnly = false)
	{
		if (!initProgressOnly)
		{
			achievement = achivment;
			SetLabels(achivmentName, ScriptLocalization.Get("Achivments/" + achivment.achievementNameID + "_Title"));
			achivmentDescription.text = ScriptLocalization.Get("Achivments/" + achivment.achievementNameID + "_Description");
			achivmentIcon.spriteName = achivment.achievementIcon;
			rewardPanel.Init(achivment.reward);
		}
		achivmentCount.text = achivment.currentCount + "/" + achivment.neededCount;
		if (achivment.achieved)
		{
			achivmentIcon.color = Color.white;
			progressBar[1].color = new Color(0.114f, 0.725f, 0.106f);
			panel.color = new Color(0.294f, 0.564f, 0f);
			SetProgressBars(progressBar, 1f);
			checkSprite.gameObject.SetActive(true);
			achivmentCount.gameObject.SetActive(false);
		}
		else
		{
			achivmentIcon.color = Color.gray;
			SetProgressBars(progressBar, (float)achivment.currentCount / (float)achivment.neededCount);
			checkSprite.gameObject.SetActive(false);
			achivmentCount.gameObject.SetActive(true);
		}
	}

	private void SetLabels(UILabel[] labels, string text)
	{
		foreach (UILabel uILabel in labels)
		{
			uILabel.text = text;
		}
	}

	private void SetProgressBars(UISprite[] progressBars, float value)
	{
		foreach (UISprite uISprite in progressBars)
		{
			uISprite.fillAmount = value;
		}
	}
}
